#include "../ast.h"
#include "../token.h"

#include <string.h>
#include <memory>
#include <string>
#include <vector>

std::unique_ptr<Node> Node::parseAST() {

  getNextToken();

  switch (currentType) {
  case Identifier:
    switch (strlen(currentValue.identifier)) {
    case 1:
        switch(currentValue.identifier[0]){
            case '!':
            case '+':
            case '*':
            case '/':
            return UnaryExpression::parseAST();
            break;
            case '&':
            case '|':
            case '^':
            return VariableDeclareStatement::parseAST();
            break;
        }
    break;
    default:
      return UnaryExpression::parseAST();
    }

    break;

  case Integer:
  case Number:
  case String:
  return 0;
    break;
  case End:
  return 0;
    break;
  }
}

std::unique_ptr<std::vector<std::unique_ptr<Node>>> parseAST(std::string code) {
  auto outputs = std::make_unique<std::vector<std::unique_ptr<Node>>>();

  // 是否结束
  while (currentType != TokenType::End) {
    auto node = Node::parseAST();
    outputs->push_back(node);
  }

  return outputs;
}
